package com.yanqu.road.server.cmd.systemgroup.newmonopolymkt.resgrab;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.newmonopolymkt.NewMonopolyMarketProto;
import com.yanqu.road.server.cmd.CrossAppointCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.systemgroup.newmonopolymkt.CrossNewMonopolyMarketGroup;
import com.yanqu.road.server.manager.systemgroup.newmonopolymkt.CrossNewMonopolyMarketMgr;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.YanQuMessageUtils;

@Cmd(code = Protocol.C_NEW_MONOPOLY_MARKET_CHANGE_TEAM_CONFIRM, desc = "修改队伍（队伍满了，需要撤回其他队伍）")
public class CrossNewMonopolyMarketResGrabChangeTeamConfirmCmd extends CrossAppointCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossNewMonopolyMarketGroup monopolyMarket = CrossNewMonopolyMarketMgr.getMarket(groupId);
        if(monopolyMarket == null){
            //todo
            return;
        }
        NewMonopolyMarketProto.NewMonopolyMarketCrossResGrabChangeTeamConfirmReqMsg msg = NewMonopolyMarketProto.NewMonopolyMarketCrossResGrabChangeTeamConfirmReqMsg.parseFrom(packet.getBytes());

        MessageHelper.sendPacket(serverId, packet.getPlayerId(), YanQuMessageUtils.buildMessage(Protocol.S_NEW_MONOPOLY_MARKET_CHANGE_TEAM_CONFIRM_FROM_CROSS,
                monopolyMarket.getMarketResRob().changeTeam(serverId, packet.getPlayerId(), msg.getAction(), msg.getResGroupId(), msg.getPosIndex(), msg.getTargetResGroupId(), msg.getTargetPosIndex())));
    }

    @Override
    public void sendData() {

    }
}
